package 力扣._2708_一个小组的最大实力值;

class Solution {
    public long maxStrength(int[] nums) {
        long max = nums[0], min = nums[0];

        for (int i = 1; i < nums.length; i++) {
            long t1 = max, t2 = min;
            max = Math.max(max, t1 * nums[i]);
            max = Math.max(max, t2 * nums[i]);
            max = Math.max(max, nums[i]);
            min = Math.min(min, t1 * nums[i]);
            min = Math.min(min, t2 * nums[i]);
            min = Math.min(min, nums[i]);
        }
        return max;
    }

    public static void main(String[] args) {
        new Solution().maxStrength(new int[]{-5, 5, -3, -7, -1, -5, 5, 1, -8});
    }
}